package j;

abstract class Animal {
	public abstract void cry();
	public abstract String getAnimalName();
}
class Simulator{
	public void playSound(Animal animal) {
		System.out.println("动物名字:"+animal.getAnimalName());
		System.out.print("动物叫声:");
		animal.cry();
	}
}
class Dog extends Animal{
	public void cry() {
		System.out.println("汪");
	}
	public String getAnimalName() {
		return"狗";
	}
}
class Cat extends Animal{
	public void cry() {
		System.out.println("喵");
	}
	public String getAnimalName() {
		return"猫";
	}
}

public class Application{
	public static void main(String args[]) {
		Simulator simulator=new Simulator();
		simulator.playSound(new Dog());
		simulator.playSound(new Cat());
	}
}
